package com.k.base.jdk;

import java.nio.charset.Charset;
import java.util.Base64;

/**
 * @author k
 */
public class Conv {
    private static final char[] HEX_DIGITS = {
            '0' , '1' , '2' , '3' ,
            '4' , '5' , '6' , '7' ,
            '8' , '9' , 'a' , 'b' ,
            'c' , 'd' , 'e' , 'f'
    };

    public String bytesToStr(byte[] b){
        return new String(b);
    }
    private static String bytesToHexStr(byte[] bytes) {
        char[] chs = new char[bytes.length * 2];
        for(int i = 0, offset = 0; i < bytes.length; i++) {
            chs[offset++] = HEX_DIGITS[bytes[i] >> 4 & 0xf];
            chs[offset++] = HEX_DIGITS[bytes[i] & 0xf];
        }
        return new String(chs);
    }
    // 19001 19002
    private static String bytesToBase64Str(byte[] bytes){
        return Base64.getEncoder().encode(bytes).toString();
    }

}
